package PowerWord.Core.Data;

import DataOperator.Loader;
import PowerWord.Core.Plan.Duty;
import SimpleDict.DictData;

public class DataManager {
	
	private Loader mLoader = new Loader();
	private WebDict mWebDict = new WebDict();
	private Sound mSound = new Sound();
	private WordList mWordList = new WordList();
	private Duty mDuty = null;
	
	private static DataManager instance = null;
	public static DataManager Instance() {
		if(instance == null) {
			instance = new DataManager();
			instance.InitData();
		}
		return instance;
	}
	private DataManager() {
	}
	// loader & sound
	private void InitData(){
		mLoader.Init(Defines.IndexPath, Defines.DictPath);
        mSound.Init();
	}
	
	public void Release() {
		mLoader.Release();
        mSound.Release();
        instance = null;
	}
	
	public void DownloadAllSounds() {
		for(int i=0; i<mWordList.GetCount(); ++i) {
			String word = mWordList.GetItem(i);
			DictData info = mLoader.LoadSimpleWordInfo(word);
			if(!info.FindSound()) {
				mSound.Download(word);
			}
		}
	}
	// word list
	public void ImportWordList(String listFileName) {
		mWordList.Import(listFileName);
	}
	
	public void ExportWordList(){
		mWordList.Export();
	}
	// duty
	public void CreateDuty(){
		
	}
}
